package cn.ruituo.adv2;

import java.util.*;

public class ArraysTest {
    public static void main(String[] args) {
        //数组和集合的互转
        List<Pengiun> list = Arrays.asList(new Pengiun("大花", 3, "帝企鹅"), new Pengiun("二花", 2, "帝企鹅"), new Pengiun("小花", 1, "小黄企鹅"));
        list=new ArrayList<>(list);//换一个List的实现类
        list.add(new Pengiun("jack",5,"豹企鹅"));
        List<Integer> ints = Arrays.asList(1,2,4,5,7,78,8,456,200);

        Pengiun pmax=Collections.max(list,new EAgeComparator());
        System.out.println("最大的企鹅是："+pmax);

        //java.util.Collections
        //max,min,sort
        Collections.sort(ints);
        System.out.println(ints);
        //
        System.out.println(">>>>>>>>>>>>>排列对象》》》》》》》》》》》》");
        for(Pengiun o:list)
            System.out.println(o);
       // Collections.sort(list);
        Collections.sort(list,new EAgeComparator());
        System.out.println("排序后");
        for(Pengiun o:list)
            System.out.println(o);
    }
}
//
class EAgeComparator implements Comparator<Pengiun> {
    @Override
    public int compare(Pengiun o1, Pengiun o2) {
        return o1.getAge()-o2.getAge();
    }
}
